DXL to get Webservice output in the enumeration attribute values

Is it possible to create a dxl which sets the enumeration attribute value in formal module from webservice.

 

 


TTL1 - Thu Nov 29 03:06:01 EST 2018

Re: DXL to get Webservice output in the enumeration attribute values
davidcs - Thu Nov 29 07:43:53 EST 2018

You can make the following HTTP requests in DXL:

The HttpVerb is an enumeration that represents the type of HTTP request:
HttpDelete
HttpGet
HttpHead
HttpPut
HttpPost

I have had some success using them. Refer to the DXL reference manual for more information.

 

 

Re: DXL to get Webservice output in the enumeration attribute values
TTL1 - Fri Nov 30 05:54:20 EST 2018

davidcs - Thu Nov 29 07:43:53 EST 2018

You can make the following HTTP requests in DXL:

The HttpVerb is an enumeration that represents the type of HTTP request:
HttpDelete
HttpGet
HttpHead
HttpPut
HttpPost

I have had some success using them. Refer to the DXL reference manual for more information.

 

 

Hello David, 

 

Thanks for the reply, could you provide us some example of how exactly we can use those in our enumeration type attributes. Because, in the DXL reference document 9.6.1, I couldn't found any related information for our requirement.

 

Re: DXL to get Webservice output in the enumeration attribute values
davidcs - Fri Nov 30 07:28:24 EST 2018

The installation directory in DOORS has an example using GET.

lib\dxl\example\oslc\sample_get.dxl

This sample is setup for OSLC, so you may have to modify the HTTP header to make it work for whichever web service you are using.

The concept is you do a GET it will return some data, probably XML, you parse that data for information and assign it to an attribute in DOORS.

Re: DXL to get Webservice output in the enumeration attribute values
OticonMTEG - Fri Nov 30 07:39:24 EST 2018

I've used DXL Services and OSLC for doors 9.6, and i'm not very impressed with the reliability of either to be honest.

I would suggest implementing a little webservice wrapper that wraps doors in batch mode, that way you have complete control of what goes on, and you don't need to worry about DWA making life difficult for you.

I've created such a wrapper in C#, super simple i think its like...100-200 lines in total, and it simply creates a new dxl script file for each request and inserts what script its supposed to run.
 

method header:

public string RunScript(string username, string password, string scriptName, string parameters)

//create dxl file

//run doors in batch mode with parameters such as username and what dxl file to run

//clean up and return the result

 

The idea is that you then have (just like DXL Services) a dxl file somewhere, that can be loaded and executed through this little wrapper dxl that is generated by the webservice.

If you are interested i can post the code for it.

Re: DXL to get Webservice output in the enumeration attribute values
TTL1 - Sat Dec 01 03:59:05 EST 2018

OticonMTEG - Fri Nov 30 07:39:24 EST 2018

I've used DXL Services and OSLC for doors 9.6, and i'm not very impressed with the reliability of either to be honest.

I would suggest implementing a little webservice wrapper that wraps doors in batch mode, that way you have complete control of what goes on, and you don't need to worry about DWA making life difficult for you.

I've created such a wrapper in C#, super simple i think its like...100-200 lines in total, and it simply creates a new dxl script file for each request and inserts what script its supposed to run.
 

method header:

public string RunScript(string username, string password, string scriptName, string parameters)

//create dxl file

//run doors in batch mode with parameters such as username and what dxl file to run

//clean up and return the result

 

The idea is that you then have (just like DXL Services) a dxl file somewhere, that can be loaded and executed through this little wrapper dxl that is generated by the webservice.

If you are interested i can post the code for it.

Thank you Martin,

 

It be very helpful if you post the code for this one. So, that we can make use it as a reference to implement our requirement. 

 

 

Re: DXL to get Webservice output in the enumeration attribute values
TTL1 - Sat Dec 01 04:01:09 EST 2018

davidcs - Fri Nov 30 07:28:24 EST 2018

The installation directory in DOORS has an example using GET.

lib\dxl\example\oslc\sample_get.dxl

This sample is setup for OSLC, so you may have to modify the HTTP header to make it work for whichever web service you are using.

The concept is you do a GET it will return some data, probably XML, you parse that data for information and assign it to an attribute in DOORS.

Thank you David, I got that example and will be working on that how we can use this example for our web service.

 

 

Re: DXL to get Webservice output in the enumeration attribute values
OticonMTEG - Mon Dec 03 03:31:49 EST 2018

TTL1 - Sat Dec 01 03:59:05 EST 2018

Thank you Martin,

 

It be very helpful if you post the code for this one. So, that we can make use it as a reference to implement our requirement. 

 

 

Its made as a wcf service, so the service class looks like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace DOORSWebServiceInterface
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
    public class Service1 : ContractInterface
    {
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }
        public string RunScript(string userName, string password, string scriptName,string parameters)
        {
            DoorsBatchManager dbm = new DoorsBatchManager();
            return dbm.RunScript(userName, password, scriptName, parameters);

        }
        public CompositeType GetDataUsingDataContract(CompositeType composite)
        {
            if (composite == null)
            {
                throw new ArgumentNullException("composite");
            }
            if (composite.BoolValue)
            {
                composite.StringValue += "Suffix";
            }
            return composite;
        }
    }
}

and then the doorsbatch manager class looks like t

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.IO;

namespace DOORSWebServiceInterface
{
    public class DoorsBatchManager
    {
        public string RunScript(string username, string password, string scriptName, string parameters)
        {
            //"D:\ibm\Rational\DOORS\9.6\bin\doors.exe" -u "username" -P "passwordOfUser" -b "fullyQualifiedPathToDXLFile" -W
            string pathToDoors = ConfigurationManager.AppSettings["DoorsPath"];
            string dxlBasePath = ConfigurationManager.AppSettings["DxlDir"];
            string dxlTempDir = ConfigurationManager.AppSettings["DxlTempDir"];
#if DEBUG
            {
                dxlTempDir = "c:/temp/";
            }
#endif
            string guid = Guid.NewGuid().ToString();
            string tempScriptPath = dxlTempDir+ guid + ".dxl";
            string outputfile = dxlTempDir + guid + ".out";

            var stream = File.CreateText(tempScriptPath);
            stream.WriteLine("pragma encoding, \"UTF-8\"");
            stream.WriteLine("pragma runLim, 0");
            stream.WriteLine("#include <"+ dxlBasePath +"/"+ scriptName+".dxl>");
            stream.WriteLine("string rv ="+scriptName + "(\"" + parameters + "\")");
            stream.WriteLine("if(!null rv && rv != \"\")");
            stream.WriteLine("{");
            stream.WriteLine("Stream out = write(\""+outputfile+"\")");
            stream.WriteLine("out << rv");
            stream.WriteLine("close out");
            stream.WriteLine("}");
            stream.Close();
            string paramString = "-u \"" + username + "\" -P \"" + password + "\" -b \"" + tempScriptPath + "\" -W";

            //"-k -data 36677@servernameofdoors"
#if DEBUG
            {
                paramString = "-k -data 36677@servernameofdoors" + paramString;
            }
#endif
            //Grabbed from: https://www.codeproject.com/Articles/25983/How-to-Execute-a-Command-in-C
            

            System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo(pathToDoors, paramString);
            // The following commands are needed to redirect the standard output.
            // This means that it will be redirected to the Process.StandardOutput StreamReader.

            procStartInfo.RedirectStandardOutput = true;
            procStartInfo.RedirectStandardError = true;
            procStartInfo.UseShellExecute = false;
            //Do not create the black window.
            procStartInfo.CreateNoWindow = true;
            // Now we create a process, assign its ProcessStartInfo and start it
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            proc.StartInfo = procStartInfo;
            proc.Start();
            proc.WaitForExit();
            // Get the output into a string
            
            //read return file
            if(File.Exists(outputfile))
            {
                string outputData = File.ReadAllText(outputfile);
                //if its empty, then just return default values
                if (!string.IsNullOrWhiteSpace(outputData))
                {
                    cleanup(dxlTempDir, guid);
                    return outputData;
                }
            }
            //cleanup(dxlTempDir, guid);
            return "failed";
            

        }

        private void cleanup(string basePath, string guid)
        {
            File.Delete(basePath+ guid + ".dxl");
            File.Delete(basePath + guid + ".out");
        }
    }
}

 

 

and then the convention is that the dxl file contains a method named the same as the file its in, and it returns a string (basically the same methodology as used by dxl services)